(function() {

	window.nameLink = function(cellData, dom) {
		console.info(dom.children().get(1).childNodes[0].data);
		var id = dom.children().eq(0).html();
		var url = keter.path + '/paper/paper/view/' + id;
		return '<a href="' + url + '">' + cellData + '</a>';
	};

	window.downloadFile = function(cellData) {
		if (cellData == "null") {
			return '无';
		}
		url = keter.reqRoot + '/download/' + cellData;
		return '<a href="' + url + '">下载</a>';
	};

	window.getName = function(cellData, dom, data) {
		return data.name;
	};

	window.operator = function(cellData, dom, data) {
		var id = dom.children().eq(0).html();
		var status = dom.children().eq(3).html();
		var url = keter.reqRoot + '/add/' + id;
		var confirm = '<a href="' + url + '">审核</a>';
		var arc_url = keter.reqRoot + '/archive/' + id;
		var archive = '<a href="#" onclick=archive(' + id + ')>归档</a>'
		if (status == 'PASS') {
			return archive;
		} else {
			return confirm;
		}
	};

	window.archive = function(id) {
		if (window.confirm('确认将当前论文进行归档处理？')) {
			$.postJSON(keter.reqRoot + '/archive/' + id, {}, function(data) {
				success(data, true);
			});
			return true;
		} else {
			return false;
		}

	};

	var get = function() {
		$.ajax({
			url : keter.reqRoot + '/getPaper',
			context : document.body
		}).done(
				function(data) {
					$('.kt_table').createTable(
							{
								data : data,
								rowFn : function(data) {
								},
								updateFn : function(data) {
									window.location.href = keter.reqRoot
											+ '/update/' + data[1];
								},
								deleteFn : function(data) {

								}
							});
				});
	};

	var main = function() {
		get();
	};

	return main();
})();
